Skip to content

WIP: Cross compilation to musl32 support#89471

Closed
wfranzini wants to merge 7 commits intoNixOS:stagingfrom
wfranzini:cc-to-musl32-staging
Closed

WIP: Cross compilation to musl32 support#89471
wfranzini wants to merge 7 commits intoNixOS:stagingfrom
wfranzini:cc-to-musl32-staging

Conversation

@wfranzini
Copy link
Contributor

This is the continuation of PR #62817
The original PR was based on master instead of the staging branch. I find easier to start a new PR.

I still need to review some commits.

Motivation for this change

Crosscompiling packages to musl32 lead to compilation errors due to the missing __stack_chk_fail_local symbol. Even building nix fails. This PR disable stackprotector for musl32.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)

  • Built on platform(s)

    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)

  • Successful compilation of the following packages:

    • nix
    • openssl
    • python2
    • python3
    • perl
  • The following packages, among many others, does not build:

    • nixFlakes
    • audit
    • openssh
    • gnupg
  • Tested execution of all binary files (usually in ./result/bin/)

  • Determined the impact on package closure size (by running nix path-info -S before and after)

  • Ensured that relevant documentation is up to date

  • Fits CONTRIBUTING.md.

wfranzini added 7 commits June 3, 2020 23:26
The makefile patch pulled from alpinelinux used to enable
stackprotector unconditionally.  This change use the nixpkgs flag
hardeningEnable.

This is required to support platform where stackprotector has
problems.
The patches from alpinelinux failed to apply to v2.8.5, on the other
hand upstream has added support for musl based system in the master
branch on github [1].

The patch has been added to the nixpkgs repo since it needs to be
modified slightly, a copyright notice has been removed, to apply
cleanly.

1. linux-audit/audit-userspace@d579a08
Disable the pipe rewind related feature since musl has no support for it.
In order to support stackprotector on musl32, this change import a
couple of patches from alpinelinux:
1. libssp_nonshared.a is built alongside musl's libc
2. the above library is automatically linked when compiling with gcc6
   or gcc7
@ofborg ofborg bot requested review from 7c6f434c, dtzWill and thoughtpolice June 4, 2020 10:51
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. labels Jun 4, 2020
})
++ optional langFortran ../gfortran-driving.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isx86_32) (fetchpatch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still an issue with gcc 8+?

@symphorien symphorien mentioned this pull request Jul 1, 2020
10 tasks
substituteInPlace $out --replace \
'-* Copyright (c) 2007-09,2011-16,2018 Red Hat Inc., Durham, North Carolina.' \
'-* Copyright (c) 2007-09,2011-16 Red Hat Inc., Durham, North Carolina.'
'-* Copyright (c) 2007-09,2012-19 Red Hat Inc., Durham, North Carolina.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch does not apply.

$  nix-build . -A pkgsStatic.audit
these derivations will be built:
  /nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv
building '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv'...
unpacking sources
unpacking source archive /nix/store/nbzjp4q72pb3rn4w03s6pwh2cqfyjvv1-audit-2.8.5.tar.gz
source root is audit-2.8.5
setting SOURCE_DATE_EPOCH to timestamp 1551474932 of file audit-2.8.5/bindings/swig/python3/audit.py
patching sources
applying patch /nix/store/38c3kkylsxv4bg1ya4gzlx1sdqcib733-Add-substitue-functions-for-strndupa-rawmemchr.patch-fix-copyright-merge-conflict
patching file ChangeLog
Hunk #1 succeeded at 32 with fuzz 2 (offset -30 lines).
patching file auparse/auparse.c
Hunk #2 succeeded at 1118 (offset -1 lines).
patching file auparse/interpret.c
Hunk #1 FAILED at 1.
Hunk #2 succeeded at 853 (offset -2 lines).
Hunk #3 succeeded at 870 (offset -2 lines).
1 out of 3 hunks FAILED -- saving rejects to file auparse/interpret.c.rej
patching file configure.ac
patching file src/ausearch-lol.c
builder for '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv' failed with exit code 1
error: build of '/nix/store/7si79l161j4vn7pkgbxis9n548q565jl-audit-2.8.5-x86_64-unknown-linux-musl.drv' failed

@ryantm ryantm marked this pull request as draft October 23, 2020 03:00
@SuperSandro2000 SuperSandro2000 added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 18, 2021
@stale
Copy link

stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@symphorien
Copy link
Member

was included in #112939

@symphorien symphorien closed this Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants